﻿/*******************************************************************************
 * Copyright @ 2017 YunSpace.Framework 版权所有
 * Author: GaoTang
 * Description: YunSpace 快速开发平台
 * Website：http://www.yunspace.com.cn
*********************************************************************************/
#region USING SYSTEM
using YunSpace.Application.WorkFlow;
using YunSpace.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using YunSpace.Domain.Entity.WorkFlow;
#endregion

namespace YunSpace.Web.Areas.WorkFlowSetting.Controllers
{
    public class ButtonsController : ControllerBase
    {
        private ButtonsApp buttonsApp = new ButtonsApp();

        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetGridJson(string keyword)
        {
            var data = buttonsApp.GetList(keyword);
            return Content(data.ToJson());
        }

        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetFormJson(string keyValue)
        {
            var data = buttonsApp.GetForm(keyValue);
            return Content(data.ToJson());
        }

        /// <summary>
        /// 提交表单
        /// </summary>
        /// <param name="buttonEntity">表单实体</param>
        [HttpPost]
        [HandlerAjaxOnly]
        [ValidateAntiForgeryToken]
        public ActionResult SubmitForm(ButtonsEntity buttonEntity, string keyValue)
        {
            buttonsApp.SubmitForm(buttonEntity, keyValue);

            return Success("操作成功。");
        }

        /// <summary>
        /// 删除表单
        /// </summary>
        /// <param name="keyValue">表单主键</param>
        [HttpPost]
        [HandlerAjaxOnly]
        [HandlerAuthorize]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteForm(string keyValue)
        {
            buttonsApp.DeleteForm(keyValue);

            return Success("删除成功。");
        }
        
    }
}


